<?php

/**
 * RestController class
 *
 * @author Julot
 * @since Friday, April 13, 2012. 10:20 AM
 */
class RestController extends ERestController {

	Const C403FORBIDDEN = 'HTTP/1.1 403 Forbidden';

	protected function renderJson($data) {
		// Bootstrap register css and javascript because it's preloaded.
		// So we must clear it before send json data.
		Yii::app()->clientScript->reset();
		parent::renderJson($data);
	}

	/**
	 * Get HTTP Status Headers From code
	 */
	public function getHttpStatus($statusCode, $default = 'C200OK') {
		switch ($statusCode) {
			case '200':
				return self::C200OK;
				break;
			case '201':
				return self::C201CREATED;
				break;
			case '401':
				return self::C401UNAUTHORIZED;
				break;
			case '403':
				return self::C403FORBIDDEN;
				break;
			case '404':
				return self::C404NOTFOUND;
				break;
			case '406':
				return self::C406NOTACCEPTABLE;
				break;
			case '500':
				return self::C500INTERNALSERVERERROR;
				break;
			default:
				return self::$default;
		}
	}

}
